C++ Arithmetic Operations



This section demonstrates basic arithmetic operations in C++, including addition, subtraction, multiplication, and division.


Arithmetic Operations

Example

  #include<iostream.h>
    #include<conio.h>
  main() {
     int a, b, add, sub, mul, div;
     
     // Initialize values
     a = 10;
     b = 5;
 
     // Perform arithmetic operations
     add = a + b;  // Addition
     sub = a - b;  // Subtraction
     mul = a * b;  // Multiplication
     div = a / b;  // Division
 
     // Output results
     cout << "Addition: " << add << endl;
     cout << "Subtraction: " << sub << endl;
     cout << "Multiplication: " << mul << endl;
     cout << "Division: " << div << endl;
 
   getch();
 }
 
Result

 Addition: 15
 Subtraction: 5
 Multiplication: 50
 Division: 2